
<h1><span class="yiyi-st" id="yiyi-12">numpy.unpackbits</span></h1>
        <blockquote>
        <p>原文：<a href="https://docs.scipy.org/doc/numpy/reference/generated/numpy.unpackbits.html">https://docs.scipy.org/doc/numpy/reference/generated/numpy.unpackbits.html</a></p>
        <p>译者：<a href="https://github.com/wizardforcel">飞龙</a> <a href="http://usyiyi.cn/">UsyiyiCN</a></p>
        <p>校对：（虚位以待）</p>
        </blockquote>
    
<dl class="function">
<dt id="numpy.unpackbits"><span class="yiyi-st" id="yiyi-13"> <code class="descclassname">numpy.</code><code class="descname">unpackbits</code><span class="sig-paren">(</span><em>myarray</em>, <em>axis=None</em><span class="sig-paren">)</span></span></dt>
<dd><p><span class="yiyi-st" id="yiyi-14">将uint8数组的元素解包成二进制值输出数组。</span></p>
<p><span class="yiyi-st" id="yiyi-15"><em class="xref py py-obj">myarray</em>的每个元素表示一个位字段，应将其解包为二进制值输出数组。</span><span class="yiyi-st" id="yiyi-16">输出数组的形状为1-D（如果<em class="xref py py-obj">轴</em>为无）或与指定的轴上拆分完成的输入数组相同的形状。</span></p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name">
<col class="field-body">
<tbody valign="top">
<tr class="field-odd field"><th class="field-name"><span class="yiyi-st" id="yiyi-17">参数：</span></th><td class="field-body"><p class="first"><span class="yiyi-st" id="yiyi-18"><strong>myarray</strong>：ndarray，uint8 type</span></p>
<blockquote>
<div><p><span class="yiyi-st" id="yiyi-19">输入数组。</span></p>
</div></blockquote>
<p><span class="yiyi-st" id="yiyi-20"><strong>axis</strong>：int，可选</span></p>
<blockquote>
<div><p><span class="yiyi-st" id="yiyi-21">沿此轴拆开包装。</span></p>
</div></blockquote>
</td>
</tr>
<tr class="field-even field"><th class="field-name"><span class="yiyi-st" id="yiyi-22">返回：</span></th><td class="field-body"><p class="first"><span class="yiyi-st" id="yiyi-23"><strong>解压缩</strong>：ndarray，uint8类型</span></p>
<blockquote class="last">
<div><p><span class="yiyi-st" id="yiyi-24">元素是二进制值（0或1）。</span></p>
</div></blockquote>
</td>
</tr>
</tbody>
</table>
<div class="admonition seealso">
<p class="first admonition-title"><span class="yiyi-st" id="yiyi-25">也可以看看</span></p>
<dl class="last docutils">
<dt><span class="yiyi-st" id="yiyi-26"><a class="reference internal" href="numpy.packbits.html#numpy.packbits" title="numpy.packbits"><code class="xref py py-obj docutils literal"><span class="pre">packbits</span></code></a></span></dt>
<dd><span class="yiyi-st" id="yiyi-27">将二进制值数组的元素包含在uint8数组中的位中。</span></dd>
</dl>
</div>
<p class="rubric"><span class="yiyi-st" id="yiyi-28">例子</span></p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">a</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([[</span><span class="mi">2</span><span class="p">],</span> <span class="p">[</span><span class="mi">7</span><span class="p">],</span> <span class="p">[</span><span class="mi">23</span><span class="p">]],</span> <span class="n">dtype</span><span class="o">=</span><span class="n">np</span><span class="o">.</span><span class="n">uint8</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span>
<span class="go">array([[ 2],</span>
<span class="go">       [ 7],</span>
<span class="go">       [23]], dtype=uint8)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">b</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">unpackbits</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="n">axis</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">b</span>
<span class="go">array([[0, 0, 0, 0, 0, 0, 1, 0],</span>
<span class="go">       [0, 0, 0, 0, 0, 1, 1, 1],</span>
<span class="go">       [0, 0, 0, 1, 0, 1, 1, 1]], dtype=uint8)</span>
</pre></div>
</div>
</dd></dl>
